home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / shell / shell.swf / scripts / DefineSprite_48 / frame_1 / DoAction.as
Text File  |  2004-07-06  |  6KB  |  276 lines

  1. function init()
  2. {
  3.    hxColorDefault = Tardis.Colors.getHex("nav");
  4.    Tardis.makeButtonShield();
  5.    makeNav();
  6.    delete makeNav;
  7.    delete init;
  8.    Tardis.ChildLock.EB.addListener(this);
  9.    onComplete();
  10. }
  11. function setActive(str)
  12. {
  13.    clearActive();
  14.    objActive = this["mc_" + str];
  15.    highlightClip(objActive);
  16. }
  17. function clearActive()
  18. {
  19.    resetClip(objActive);
  20.    objActive = null;
  21. }
  22. function enable()
  23. {
  24.    var obj;
  25.    for(var o in this)
  26.    {
  27.       obj = this[o];
  28.       if(obj.enabled != undefined)
  29.       {
  30.          obj.enabled = true;
  31.       }
  32.    }
  33. }
  34. function disable()
  35. {
  36.    var obj;
  37.    for(var o in this)
  38.    {
  39.       obj = this[o];
  40.       if(obj.enabled != undefined)
  41.       {
  42.          obj.enabled = false;
  43.       }
  44.    }
  45. }
  46. function show()
  47. {
  48.    _visible = true;
  49. }
  50. function hide()
  51. {
  52.    _visible = false;
  53. }
  54. function childLockSet(val)
  55. {
  56.    var mc;
  57.    for(var o in this)
  58.    {
  59.       mc = this[o];
  60.       if(typeof mc == "movieclip" && mc._name.indexOf("kids") == -1 && mc._name.indexOf("_ha") == -1)
  61.       {
  62.          mc._visible = !val;
  63.       }
  64.    }
  65. }
  66. function splashOff()
  67. {
  68.    var mc = this["mc_" + strSplashActiveButton];
  69.    if(objActive != mc)
  70.    {
  71.       resetClip(mc);
  72.    }
  73.    strSplashActiveButton = "";
  74. }
  75. function splashOn(str)
  76. {
  77.    strSplashActiveButton = str;
  78.    highlightClip(this["mc_" + str]);
  79. }
  80. function __onOver()
  81. {
  82.    lingo("cursor 280");
  83.    if(objActive == this)
  84.    {
  85.       return undefined;
  86.    }
  87.    if(Tardis.ActiveSection == null)
  88.    {
  89.       splashOff();
  90.       splashOn(this.id);
  91.    }
  92.    else
  93.    {
  94.       highlightClip(this);
  95.    }
  96.    onOver(this.id);
  97.    updateAfterEvent();
  98. }
  99. function __onOut()
  100. {
  101.    lingo("cursor -1");
  102.    if(objActive == this)
  103.    {
  104.       return undefined;
  105.    }
  106.    if(Tardis.ActiveSection != null)
  107.    {
  108.       resetClip(this);
  109.    }
  110.    onOut();
  111.    updateAfterEvent();
  112. }
  113. function __onUp()
  114. {
  115.    if(this.disabled == "true")
  116.    {
  117.       return undefined;
  118.    }
  119.    trace("click a nav item - shut all overlays");
  120.    Tardis.OverlayController.closeAll();
  121.    if(objActive != this)
  122.    {
  123.       resetClip(objActive);
  124.       objActive = this;
  125.    }
  126.    trace("ID:" + this.id);
  127.    onUp(this.id);
  128. }
  129. function makeNav()
  130. {
  131.    var len = Tardis.Sections.length;
  132.    var clp;
  133.    var nd;
  134.    var strID;
  135.    var arrClips = [];
  136.    var arrMasks = [];
  137.    var arrHAclips = [];
  138.    var hitareaX = 15;
  139.    var totalButtonTextWidth;
  140.    var n = 0;
  141.    while(n < len)
  142.    {
  143.       var w = arrHitareaWidths[n];
  144.       nd = Tardis.Sections.item(n);
  145.       strID = nd.id;
  146.       clp = this.createEmptyMovieClip("mc_" + strID,Tardis.depth++);
  147.       clp.createTextField("txt",Tardis.depth++,0,0,100,50);
  148.       for(var o in nd)
  149.       {
  150.          clp[o] = nd[o];
  151.       }
  152.       clp.hxOverColor = Tardis.Colors.getHex(strID);
  153.       with(clp.txt)
  154.       {
  155.          embedFonts = true;
  156.          html = true;
  157.          htmlText = "<font face=\"TardisFGExtraBoldCondensed\" size=\"24\">" + nd.label + "</font>";
  158.          autoSize = "left";
  159.          textColor = hxColorDefault;
  160.       }
  161.       totalButtonTextWidth += clp.txt._width;
  162.       clp.onRollOver = __onOver;
  163.       clp.onReleaseOutside = __onOut;
  164.       clp.onRollOut = __onOut;
  165.       if(!(Tardis.PLAY_MODE == "browser" && nd.sandbox == "true"))
  166.       {
  167.          clp.onRelease = __onUp;
  168.       }
  169.       arrClips.push(clp);
  170.       n++;
  171.    }
  172.    Tardis.spaceEvenly(arrClips,15,785,null,true);
  173.    var l = arrClips.length;
  174.    var posHorizontal = 15;
  175.    var buttonPadding = (770 - totalButtonTextWidth) / (l * 2 - 2);
  176.    var i = 0;
  177.    while(i < l)
  178.    {
  179.       var clp = arrClips[i];
  180.       var maskX;
  181.       var maskW;
  182.       if(i == 0)
  183.       {
  184.          maskX = clp._x;
  185.          maskW = maskX + clp._width + buttonPadding;
  186.       }
  187.       else if(i == l - 1)
  188.       {
  189.          maskX = clp._x - buttonPadding;
  190.          maskW = 770 + posHorizontal;
  191.       }
  192.       else
  193.       {
  194.          maskX = clp._x - buttonPadding;
  195.          maskW = maskX + clp._width + buttonPadding * 2;
  196.       }
  197.       h = clp.txt.textHeight;
  198.       clpHA = this.createEmptyMovieClip("mc_" + strID + "_ha",Tardis.depth++);
  199.       clpHA.moveTo(maskX,0);
  200.       clpHA.beginFill(16711680);
  201.       clpHA.lineTo(maskW,0);
  202.       clpHA.lineTo(maskW,h);
  203.       clpHA.lineTo(maskX,h);
  204.       clpHA.lineTo(maskX,0);
  205.       clpHA.endFill();
  206.       clp.hitArea = clpHA;
  207.       clp.hitArea._visible = false;
  208.       i++;
  209.    }
  210. }
  211. function highlightClip(mc)
  212. {
  213.    mc.txt.textColor = mc.hxOverColor;
  214.    if(faded)
  215.    {
  216.       mc._alpha = 100;
  217.    }
  218. }
  219. function resetClip(mc)
  220. {
  221.    mc.txt.textColor = hxColorDefault;
  222.    if(faded)
  223.    {
  224.       mc._alpha = FADE_LIMIT;
  225.    }
  226. }
  227. function fadeOthers(strIDExcept, strUpDown)
  228. {
  229.    var len = Tardis.Sections.length;
  230.    var strF = strUpDown != "down" ? "fadeUpEnterFrame" : "fadeDownEnterFrame";
  231.    var nd;
  232.    var strID;
  233.    var n = 0;
  234.    while(n < len)
  235.    {
  236.       nd = Tardis.Sections.item(n);
  237.       strID = nd.id;
  238.       if(strID != strIDExcept)
  239.       {
  240.          mc = this["mc_" + strID];
  241.          mc.onEnterFrame = this[strF];
  242.       }
  243.       n++;
  244.    }
  245.    this.faded = strUpDown == "down";
  246. }
  247. function fadeDownEnterFrame()
  248. {
  249.    with(this)
  250.    {
  251.       if(_alpha > FADE_LIMIT)
  252.       {
  253.          _alpha -= 10;
  254.       }
  255.       else
  256.       {
  257.          onEnterFrame = null;
  258.       }
  259.    }
  260. }
  261. function fadeUpEnterFrame()
  262. {
  263.    with(this)
  264.    {
  265.       if(_alpha < 100)
  266.       {
  267.          _alpha += 10;
  268.       }
  269.       else
  270.       {
  271.          onEnterFrame = null;
  272.       }
  273.    }
  274. }
  275. FADE_LIMIT = 50;
  276.